﻿/*
    This file is part of News Worm.

    News Worm is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    News Worm is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with News Worm.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;

namespace NewsWorm
{
    internal class NonCachedItem
    {
        internal NonCachedItem(string FeedTitle, bool DoNotify)
        {
            m_FeedTitle = FeedTitle;
            m_DoNotify = DoNotify;
        }

        private string m_FeedTitle;
        private int m_ArticleCount;
        private bool m_DoNotify;

        internal bool HasNotificationEnabled {
            get { return m_DoNotify; }
        }

        internal void SetArticleCount(int ArticleCount) {
            m_ArticleCount = ArticleCount;
        }

        internal string FeedTitle {
            get { return m_FeedTitle; }
        }

        internal string GetTruncatedFeedTitle() {

            string ret = "";

            if ( m_FeedTitle.Length >= 25 )
                ret = m_FeedTitle.Substring( 0, 22 ) + "...";
            else
                ret = m_FeedTitle;

            return ret;

        }

        internal int ArticleCount
        {
            get { return m_ArticleCount; }
        }

        public override bool Equals( object obj ) {
            
            NonCachedItem item = (NonCachedItem)obj;
            
            if ( item.FeedTitle.Equals( this.FeedTitle ) )
                return true;

            return false;
        }

        public override int GetHashCode() {
            return base.GetHashCode();
        }
    }
}
